/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.entityTable;
import sql.AConnection;

/**
 *
 * @author aragon
 */
public class Room extends AConnection implements entityTable<Room>{
    private String idRoon;
    private String roomName;
    private String size;
    private String idLocal;
    private String hide;

    public Room(String idRoon, String roomName, String size, String idLocal, String hide) {
        this.idRoon = idRoon;
        this.roomName = roomName;
        this.size = size;
        this.idLocal = idLocal;
        this.hide = hide;
    }

    public Room() {
    }


    public boolean select() {
        try {
            String query = "SELECT TenPhong,SucChua,idKhu, FROM phonghoc WHERE idPhong = ? and AnHien =1";
            Connection connection = getConnection();
            PreparedStatement ps = connection.prepareStatement(query);
            ps.setString(1, getIdRoon());
            ResultSet rs=ps.executeQuery();
            if(rs.next()){
                setRoomName(rs.getString("TenPhong"));
                setSize(rs.getString("SucChua"));
                setIdLocal(rs.getString("idKhu"));
                setHide("1");
                return true;
            }else{
                return false;
            }
        } catch (SQLException ex) {
            return false;
        }


    }

    public ResultSet selectDB() {
         try {
            String query = "SELECT idPhong,TenPhong,SucChua,idKhu FROM phonghoc WHERE idKhu = ? and AnHien =1";
            Connection connection = getConnection();
            PreparedStatement ps = connection.prepareStatement(query);
            ps.setString(1, getIdLocal());
            ResultSet rs=ps.executeQuery();
            return rs;
        } catch (SQLException ex) {
            return null;
        }


    }

    public boolean insert() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean update() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean remove() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getHide() {
        return hide;
    }

    public void setHide(String hide) {
        this.hide = hide;
    }

    public String getIdLocal() {
        return idLocal;
    }

    public void setIdLocal(String idLocal) {
        this.idLocal = idLocal;
    }

    public String getIdRoon() {
        return idRoon;
    }

    public void setIdRoon(String idRoon) {
        this.idRoon = idRoon;
    }

    public String getRoomName() {
        return roomName;
    }

    public void setRoomName(String roomName) {
        this.roomName = roomName;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

}
